package com.wc.alorithm_luogu.P3612;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @Author congege
 * @Description
 * @Date Created in 2023/9/14-12:59
 */
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        StringBuffer s = new StringBuffer(scan.next());
        long preIdx = Long.parseLong(scan.next());
        scan.close();
        int len = s.length();

        ArrayList<Long> dps = new ArrayList<>();
        double floor = 0;
        long floorNumber = len * (long) Math.pow(2, floor);
        while (floorNumber < preIdx) {
            dps.add(floorNumber);
            floor++;
            floorNumber = len * (long) Math.pow(2, floor);
        }
        dps.add(floorNumber);

        int dpsSize = dps.size();
        while (len < preIdx) {
            for (int i = 0; i < dpsSize; i++) {
                if (preIdx <= dps.get(i)) {
                    preIdx = preIdx - dps.get(i - 1) - 1;
                    /**
                     * 刚好是重复的首字母
                     */
                    if (preIdx == 0) {
                        preIdx = len - i + 1;
                    }
                    break;
                }
            }
        }


        System.out.println(s.charAt((int) preIdx - 1));

    }
}
